<template>
  <div class='content'>
    <el-form :model="formLabel" :rules="rules" :ref="formLabel" :label-position="labelPosition" label-width="80px"
      class="formsize">
      <el-form-item label="库存类型" prop="inventoryType">
        <el-select v-model="formLabel.inventoryType" placeholder="请选择库存类型">
          <el-option label="生活用品" value="live"></el-option>
          <el-option label="美味食物" value="food"></el-option>
          <el-option label="数码3c " value="3c"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="产品名称" prop="name">
        <el-input v-model="formLabel.name"></el-input>
      </el-form-item>
      <el-form-item label="产品编号" prop="id">
        <el-input v-model="formLabel.id"></el-input>
      </el-form-item>
      <el-form-item label="产品型号" prop="brand">
        <el-input v-model="formLabel.brand"></el-input>
      </el-form-item>
      <el-form-item label="产品品牌" prop="brand">
        <el-input v-model="formLabel.brand"></el-input>
      </el-form-item>
      <el-form-item label="产品类型" prop="type">
        <el-input v-model="formLabel.type"></el-input>
      </el-form-item>
      <el-form-item label="产品数量" prop="num">
        <el-input v-model="formLabel.num"></el-input>
      </el-form-item>
      <el-form-item label="产品单价" prop="price">
        <el-input v-model="formLabel.price"></el-input>
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="formLabel.note"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认添加</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    //import引入的组件需要注入到对象中才能使用
    components: {},
    data() {
      //这里存放数据
      return {
        labelPosition: 'left',
        formLabel: {
          inventoryType: '',
          name: '',
          id: '',
          brand: '',
          model: '',
          type: '',
          num: '',
          price: '',
          note: ''
        },
        rules: {
          inventoryType: [{
            required: true
          }],
          name: [{
              required: true,
              message: '请输入活动名称',
              trigger: 'blur'
            },
            {
              min: 3,
              max: 5,
              message: '长度在 3 到 5 个字符',
              trigger: 'blur'
            }
          ],
          id: [{
            required: true
          }],
          brand: [{
            required: true
          }],
          model: [{
            required: true
          }],
          type: [{
            required: true
          }],
          num: [{
            required: true
          }],
          price: [{
            required: true
          }],
        }
      };
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
      onSubmit() {
        console.log(this.formLabel)
      }
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created() {

    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {

    },
    beforeCreate() {}, //生命周期 - 创建之前
    beforeMount() {}, //生命周期 - 挂载之前
    beforeUpdate() {}, //生命周期 - 更新之前
    updated() {}, //生命周期 - 更新之后
    beforeDestroy() {}, //生命周期 - 销毁之前
    destroyed() {}, //生命周期 - 销毁完成
    activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
  }

</script>
<style lang='scss' scoped>
  @import '~@/styles/chow.scss' ;//引入公共css类
  .el-select { width: 320px;}

</style>
